package cn.com.do4u.controller;

import cn.com.do4u.domain.Radcheck;
import cn.com.do4u.service.RadcheckService;
import com.jfinal.core.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * Created by chenyu on 15/12/8.
 */
public class LoginCtrl extends Controller {

    public void index(){
        render("login.html");

    }

    public void login(){
        Radcheck radcheck = getModel(Radcheck.class);

//        boolean is = Radcheck.me.login(getPara("radcheck.username"),getPara("radcheck.value"));
        boolean is = RadcheckService.me.login(getPara("radcheck.username"),getPara("radcheck.value"));


        HttpSession session = getRequest().getSession();
        session.setAttribute("userName",getPara("radcheck.username"));
        session.setAttribute("ip",getRequest().getRemoteAddr());


        if(is){
            render("admin-index.html");
        }else {
            render("login.html");
        }
    }


}
